"use strict";

var ue = UE.getEditor('container', {
    //设置配置项，参考文档 http://fex.baidu.com/ueditor/#start-config
    toolbars: [["source", "removeformat", "undo", "redo", "|", "fontsize", "|", "bold", "italic", "underline", "|", "forecolor", "backcolor", "blockquote", "horizontal", "|", "link", "insertimage", "music", "insertvideo", "|", "justifyleft", "justifycenter", "justifyright", "|", "rowspacingtop", "rowspacingbottom", "lineheight", "insertorderedlist", "insertunorderedlist", "|", "imagenone", "imageleft", "imageright", "imagecenter"]],
    wordCount: false,
    elementPathEnabled: false,
    initialFrameHeight: 450,
    autoHeightEnabled: false,
    allowDivTransToP: false,
    autoClearinitialContent: true,
    topOffset: 80,
    saveInterval: 60000,
    disabledTableInTable: false,
    initialFrameWidth: 640,
    customDomain: true,
    fontsize: [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 24, 36]
});

ue.ready(function () {
    //让编辑器获得焦点
    //ue.focus();

    //设置编辑器的内容，可用于设置默认内容，或者用于插入模板
    //ue.setContent('<p>hello</p>');

    //追加编辑器内容
    //ue.setContent('', true);

    //判断编辑器里面是否有内容，布尔类型，保存的时候判断
    //ue.hasContents();

    //获取html内容，保存文档/模板
    //var html = ue.getContent();

    //自定义请求参数，传入参数表,添加到已有参数表里
    /*ue.execCommand('serverparam', {
        token: 'bona'
    });*/

    /*$('[title]').tooltip();*/
    $('[data-toggle="tooltip"]').tooltip();
});

var url = 'http://gateway.bigdata.cloud.dayang.com:8088/cluegather/v3/subscribe/mediaType/list',
    token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0ZW5hbnRJZCI6Ijk5IiwiZXhwIjoxNTMzMjAyNzQ2OTQwLCJ1c2VySWQiOiIxMTQiLCJpYXQiOjE1MzMxMTYzNDY5NDAsImFwcElkIjoiY2xpZW50In0.OPUsUzj6JFbNhArTkvCjphAtHNp_bXQpH2N41eTbdbo';

function getMediaList1() {
    return new Promise(function (resolve, reject) {
        $.ajax({
            type: "get",
            async: true,
            beforeSend: function beforeSend(XHR) {
                XHR.setRequestHeader("token", token);
            },
            url: url,
            success: function success(data) {
                resolve(data);
            }
        });
    });
}

function getMediaList2(y) {
    return new Promise(function (resolve, reject) {
        $.ajax({
            type: "get",
            async: true,
            beforeSend: function beforeSend(XHR) {
                XHR.setRequestHeader("token", token);
            },
            url: url,
            success: function success(data) {
                resolve({
                    data1: y,
                    data2: data
                });
            }
        });
    });
}

/*getMediaList1().then(getMediaList2)
    .then(function (y) {
        console.log(y);
    });*/

var a = 1;
